package views

import (
	"net/http"
	"mdbook/gorilla/context"
)

// 管理功能
func PostEditHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	tmpls["admin"].ExecuteTemplate(w, "editor.tpl", nil)
}

func PostListHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	context.Set(r, tplKey, "admin")
	model := newModel(r, "页面管理", nil)
	view, err := renderView(r, "posts.tpl", model)
	if err != nil {
		renderError(w, r, err)
	}
	w.Write(view)
}

func HelpHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	tmpls["admin"].ExecuteTemplate(w, "help.tpl", nil)
}


